<template>
 <h2>销售开发</h2>

 <el-form :model="sellForm" label-width="120px" >
    <el-form-item label="客户名称">
        <el-select
      v-model="sellForm.custid"
      placeholder="请选择客户"
      size="large"
      style="width:80%"
    >
      <el-option
        v-for="item in custList"
        :key="item.id"
        :label="item.custName"
        :value="item.id"
      />
    </el-select>
    </el-form-item>
     <el-form-item label="销售渠道">
        <el-select v-model="sellForm.channelId" placeholder="请选择渠道" style="width: 80%">
        <el-option label="自媒体" value="0" />
        <el-option label="网络推广" value="1" />
        <el-option label="老客户介绍" value="2" />
        <el-option label="二次客户" value="3" />
     
      </el-select>
    </el-form-item>
    <el-form-item label="销售金额">
      <el-input v-model="sellForm.money" style="width: 80%"/>
    </el-form-item>

    <el-form-item label="开发阶段">
      <el-select v-model="sellForm.nowStep" placeholder="请选择" style="width: 80%">
        <el-option label="接触" value="接触" />
        <el-option label="报价" value="报价" />
        <el-option label="签约" value="签约" />
     
      </el-select>
    </el-form-item>
    <el-form-item label="业务员">
      <el-input v-model="sellForm.empId"  style="width: 80%" readonly="readonly"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="saveSellForm">保存</el-button>
      <el-button>取消</el-button>
    </el-form-item>

  </el-form>


</template>

<script setup>
import axios from 'axios';
import { onMounted, reactive } from 'vue';
import { ref } from 'vue';
import { ElMessage } from 'element-plus';


const sellForm=reactive({
custid:'',
channelId:'',
money:0.0,
nowStep:'',
empId:100
}
);
const custList=ref([]);
onMounted(function(){
axios.get("http://localhost:8081/listAllCust")
.then(
(response)=>{
  console.log(response.data);
custList.value=response.data;
})
.catch(
  (error)=>{
    console.log(error);
  }
)});

function saveSellForm(){
axios.post("http://localhost:8081/saveSelljh",sellForm)
.then(
(response)=>{
  console.log(response.data);
  if(response.data.code==200){
    ElMessage(response.data.msg);
  }
  else{
    ElMessage(response.data.msg);
  }
})
.catch(
  (error)=>{
    console.log(error);
  }
);

}

</script>

<style scoped>

</style>